package com.xm;

import com.xm.entity.HomeInfoEntity;
import com.xm.entity.HomeInfoNewEntity;
import com.xm.entity.UserEntity;
import com.xm.factory.service.ConfigurationFactory;
import com.xm.service.impl.GetXmGoodsServiceImpl;

import java.util.List;
import java.util.Map;
import java.util.Scanner;

/**
 * @Author tianqin
 * @Date 2024/7/29 13:45
 * 获取商品以及用户信息
 */
public class GetMain {
    public static void main(String[] args) {
        // 获取所有活动线程的堆栈跟踪
        Map<Thread, StackTraceElement[]> allThreads = Thread.getAllStackTraces();

        // 遍历并打印线程信息
        for (Thread thread : allThreads.keySet()) {
            System.out.println("线程名： " + thread.getName());
            System.out.println("线程ID: " + thread.getId());
            System.out.println("线程状态： " + thread.getState());
            System.out.println("线程优先级： " + thread.getPriority());
            System.out.println("线程所属组： " + thread.getThreadGroup().getName());
            System.out.println("-----------------------------");

            //返回的数据已经加密
            // getUserScore();
        }
        System.out.println("请输出查询的商品名称：");
        getGoodsList(new Scanner(System.in).next());
    }

    // 获取矿币余额
    public static void getUserScore() {
        GetXmGoodsServiceImpl getXmGoodsService = new GetXmGoodsServiceImpl();
        getXmGoodsService.getUserScore("40019ab3-668b-4e1a-98f8-e865e614ecf6");
    }
    // 获取首页数据
    public static void getGoodsList(String shopName){
        GetXmGoodsServiceImpl getXmGoodsService = new GetXmGoodsServiceImpl();
        // 获取用户配置
        UserEntity user = ConfigurationFactory.getImplByKey("TQ");
        List<HomeInfoNewEntity> goodsList = getXmGoodsService.getGoodsList(user.getPassCode(), shopName);
        goodsList.forEach(homeInfoNewEntity -> {
            System.out.println("=============================商品信息==============================");
            System.out.println("商品统一ID:"+ homeInfoNewEntity.getArchiveId());
            System.out.println("名称:"+ homeInfoNewEntity.getName());
            System.out.println("用户挂载数量:"+ homeInfoNewEntity.getSellingCount());
            System.out.println("价格:"+ homeInfoNewEntity.getPrice());
            System.out.println("商品购买ID:"+homeInfoNewEntity.getId());
            System.out.println("用户ID:"+homeInfoNewEntity.getUid());
        });
    }

}
